﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="AttachmentsBrowser.aspx.cs"
    Inherits="SCFHS.Shared.Attachments" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>إدارة المرفقات</title>
    <link href="../Style/Main/Shared.css" rel="stylesheet" type="text/css" />
    <script src="../Scripts/jquery-1.4.1.js" type="text/javascript"></script>
    <script src="../Scripts/jquery-1.4.1.min.js" type="text/javascript"></script>
    <script type="text/javascript">
        function EditbtnClick(ths) {
            var parentRow = $(ths).parents(".ImageDescription");
            var descriptionDiv = $(parentRow).find(".description");
            $(descriptionDiv).css("display", "none");

            var descriptionDivEdit = $(parentRow).find(".editDescription");
            $(descriptionDivEdit).css("display", "inline");
        }

        function SavebtnClick(ths) {
            var parentRow = $(ths).parents(".ImageDescription");
            var descriptionDiv = $(parentRow).find(".description");
            $(descriptionDiv).css("display", "inline");

            var descriptionDivEdit = $(parentRow).find(".editDescription");
            $(descriptionDivEdit).css("display", "none");

            var txtToSave = $(descriptionDivEdit).find("textarea");
            $("#hdfTxtToSave").val($(txtToSave).get(0).innerText);
        }
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <asp:ScriptManager ID="ScriptManager1" runat="server">
    </asp:ScriptManager>
    <asp:UpdatePanel runat="server">
        <ContentTemplate>
            <div class="attachments">
                <input type="hidden" id="hdfTxtToSave" value=" " runat="server" />
                <asp:FormView runat="server" AllowPaging="True" ID="frmvAttachmentsImages" CellPadding="4"
                    PagerSettings-Mode="NextPreviousFirstLast" ForeColor="#333333" OnPageIndexChanging="frmvAttachmentsImages_PageIndexChanging">
                    <EditRowStyle BackColor="#999999" />
                    <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
                    <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
                    <ItemTemplate>
                        <div class="ImageViewer">
                            <div class="imgControl row">
                                <asp:Button Text="طباعة" runat="server" CommandArgument='<%# Eval("img_id") %>' ID="btnPrint" />
                                <asp:Button Text="حذف" runat="server" CommandArgument='<%# Eval("img_id") %>' ID="btnDelete"
                                    OnClick="btnDelete_Click" />
                            </div>
                            <div style="height: 630px; direction: ltr; overflow-x: hidden; overflow-y: scroll;">
                                <asp:Image ImageUrl='<%#  GetImage(DataBinder.Eval(Container.DataItem, "img_id").ToString())%>'
                                    runat="server" Height="750px" Width="550px" />
                            </div>
                        </div>
                        <div class="ImageDescription">
                            <div class="description">
                                <div class="descriptionContent">
                                    <%# Eval("img_description") %>
                                </div>
                                <div class="descriptionControl Edit">
                                    <input type="button" name="btnEdit" value="تعديل" class=".btnEdit" onclick="EditbtnClick(this)" />
                                </div>
                            </div>
                            <div class="editDescription" style="display: none;">
                                <div class="discriptionContent">
                                    <textarea style="width: 250px;"><%# Eval("img_description") %></textarea>
                                </div>
                                <div class="descriptionControl Save">
                                    <asp:Button Text="حفظ" ID="btnSave" runat="server" CommandArgument='<%# Eval("img_id") %>'
                                        OnClick="btnSave_Click" OnClientClick="SavebtnClick(this)" />
                                    <input type="button" name="btnCancel" value="إلغاء" class=".btnDelete" onclick="CancelbtnClick(this)" />
                                </div>
                            </div>
                        </div>
                    </ItemTemplate>
                    <PagerSettings Mode="NextPreviousFirstLast"></PagerSettings>
                    <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" Font-Bold="true" />
                    <RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
                </asp:FormView>
            </div>
        </ContentTemplate>
    </asp:UpdatePanel>
    </form>
</body>
</html>
